﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BrokerBase.Lib.Policy;

namespace broker.duty.YG
{
    /// <summary>
    /// 阳光人寿财富双账户少儿两全保险（万能型）（AULB）
    /// </summary>
    class Class3
    {
        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if (ppa.SchemePeriodActing.InsurantStates.Contains("身故"))
            {
                da.Value = ppa.Amount + ppa.GetDutyTotalValue("稳健型个人账户") + ppa.GetDutyTotalValue("进取型个人账户");
                ppa.IsCurrentFinish = true;
            }
        }

        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if (ppa.Age==80)
            {
                da.Value = ppa.GetDutyTotalValue("稳健型个人账户") + ppa.GetDutyTotalValue("进取型个人账户");
                ppa.IsCurrentFinish = true;
            }
        }


        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if (ppa.Period>=3 && ppa.Period % 3 ==0)
            {
                double p1 = (double)ppa.SchemePeriodActing.SchemeActing.GetAuxConfigValue("进取型子账户比例");
                double p2 = (double)ppa.SchemePeriodActing.SchemeActing.GetAuxConfigValue("稳健型子账户比例");

                IDutyActing da1 = ppa.DutyActings.FirstOrDefault(p => p.Duty.Name == "稳健型个人账户");
                IDutyActing da2 = ppa.DutyActings.FirstOrDefault(p => p.Duty.Name == "进取型个人账户");

                da1.Value += ppa.Fee * 0.02 * p1;
                da2.Value += ppa.Fee * 0.02 * p2;

                da.Description = "持续交费特别奖金已经计入个人账户";
            }
        }

        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            double f = (double)ppa.SchemePeriodActing.SchemeActing.GetAuxConfigValue("分红率(预估)");

            
            if (ppa.Fee >= 6000)
            {
                da.Value = ppa.Fee * 0.95  * (1+f);
            }
            else
            {
                if (ppa.Period == 0)
                    da.Value = ppa.Fee * 0.8  * (1 + f);
                else if (ppa.Period == 1)
                    da.Value = ppa.Fee * 0.9  * (1 + f);
                else if (ppa.Period >= 2)
                    da.Value = ppa.Fee * 0.95  * (1 + f);
            }
        }
    }
}
